import requests
import json

headers = {
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "content-type": "application/json",
    "origin": "https://www.qcc.com",
    "priority": "u=1, i",
    "referer": "https://www.qcc.com/web/search?key=shunfeng",
    "sec-ch-ua": "\"Chromium\";v=\"142\", \"Microsoft Edge\";v=\"142\", \"Not_A Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0",
    "x-pid": "743a9b891756b1b2941ef1de4217d6cc",
    "x-requested-with": "XMLHttpRequest"
}
cookies = {
    "qcc_did": "e54d5cf2-6a50-4958-8ddc-7d3eb40987f7",
    "QCCSESSID": "be65be761d849b377e1f13af3c",
    "UM_distinctid": "19a5d49a13434f-013759f5d1fb67-4c657b58-1bcab9-19a5d49a1351cc1",
    "_c_WBKFRo": "kX0TqFYcEMb0ZPdI0Iru5JnudgA3taCrYBk5fP7B",
    "CNZZDATA1254842228": "672668698-1762501698-https%253A%252F%252Fcn.bing.com%252F%7C1762507361",
    "acw_tc": "0a47318217625080724952017e79721072e298d61f2ce36fc914b12c2e127c"
}
url = "https://www.qcc.com/api/search/searchMulti"
data = {
    "searchKey": "shunfeng",
    "pageIndex": 1,
    "pageSize": 20
}

import execjs

with open("14.js", "r", encoding="utf-8") as f:
    js_code = f.read()
js = execjs.compile(js_code)
kv = js.call("getKey_Value", data["searchKey"], data["pageIndex"])
print(kv[0], kv[1])
headers[kv[0]] = kv[1]

# 禁用代理
proxies = {
    'http': None,
    'https': None
}

data = json.dumps(data, separators=(',', ':'))
response = requests.post(url, headers=headers, cookies=cookies, data=data, proxies=proxies)


print(response.text)
print(response)
